const setting = require('./setting/setting.js');

App({
	onLaunch: function (options) {
    this.globalData = {
      current_campus:'开元校区',
      navigationData:null,
    };
    //加载校园导览数据
    this.loadCampus(), this.loadNavigation(),this.loadLocalUserInfo()
		if (!wx.cloud) {
			console.error('请使用 2.2.3 或以上的基础库以使用云能力')
		} else {
			wx.cloud.init({
				// env 参数说明：
				//   env 参数决定接下来小程序发起的云开发调用（wx.cloud.xxx）会默认请求到哪个云环境的资源
				//   此处请填入环境 ID, 环境 ID 可打开云控制台查看
				//   如不填则使用默认环境（第一个创建的环境）
				// env: 'my-env-id',
				env: setting.CLOUD_ID,
				traceUser: true,
			})
    }

		// 用于自定义导航栏
		wx.getSystemInfo({
			success: e => {
				this.globalData.statusBar = e.statusBarHeight;
				let capsule = wx.getMenuButtonBoundingClientRect();
				if (capsule) {
					this.globalData.custom = capsule;
					this.globalData.customBar = capsule.bottom + capsule.top - e.statusBarHeight;
				} else {
					this.globalData.customBar = e.statusBarHeight + 50;
				} 
			}
		});
	},
  loadCampus: function() {
    var a = this, t = wx.getStorageSync("current_campus");
    this.globalData.current_campus = t || "开元校区";
},
  loadNavigation: function() {
    var a = this.globalData.current_campus, t = null;
    "开元校区" == a ? t = require("./projects/A00/navigation/data/kaiyuan.js") : "西苑校区" == a && (t = require("./projects/A00/navigation/data/xiyuan.js"));
    var o = t.navigation;
    try {
        wx.setStorageSync("current_campus", a);
    } catch (a) {}
    this.globalData.navigationData = o;
},
loadLocalUserInfo: function() {
  var a = this;
  wx.getStorage({
      key: "userInfo",
      success: function(t) {
          a.globalData.userInfo = t.data;
      }
  }), wx.getStorage({
      key: "openid",
      success: function(t) {
          a.globalData.openid = t.data;
      }
  });
},
	/*
	onShow: function (options) {
		// 启动，或者从后台进入前台
		//GroupBiz.initGroupShareTicket(options);
	},
	onHide: function () {
		// 小程序从前台进入后台
		//GroupBiz.clearGroupShareTicket();
	}*/
})